﻿<?php
if (!defined('SERVER_ROOT'))
    exit('No direct script access allowed');

class doimatkhau_Model extends Model {

    function __construct() {
        parent::__construct();
    }

    public function do_doimatkhau() {

     //   if ($v_login == 1) {

            $passold = isset($_POST['txtPassOld']) ? $this->replace_bad_char($_POST['txtPassOld']) : null;
            $passnew = isset($_POST['txtPass1']) ? $this->replace_bad_char($_POST['txtPass1']) : null;
            $tendangnhap = Session::get(TIEP_DAU_NGU_SESSION.'TAI_KHOAN');
            //echo '<script>alert("'.$tendangnhap.'");</script>';


           // $arr_user = $this->db->ExecuteCursor("BEGIN HETHONG.CHECK_DANG_NHAP(:CUR,'$tendangnhap','$passold'); END;", 'CUR');
          //  while ($arr = $arr_user->FetchRow()) {
                $result = $this->db->PrepareSP("BEGIN HETHONG.DOI_MAT_KHAU(:P_VAL,:P_TEN_DANG_NHAP,:P_MAT_KHAU); END;");
                $this->db->OutParameter($result, $P_VAL, 'P_VAL');
                $this->db->InParameter($result, $tendangnhap, 'P_TEN_DANG_NHAP'); 
                $this->db->InParameter($result, $passnew, 'P_MAT_KHAU');

                $chaythutuc = $this->db->Execute($result);
                echo $tendangnhap;
                if ($chaythutuc) {
                    if ($P_VAL == 'THANH_CONG') {
                        //$this->popup_exec_done();
                        $this->exec_done($this->goback_url);
                    } else {
                        $this->popup_exec_fail(__('Có lỗi xảy ra!'));
                        return;
                    }
                }
          //  }





//               $_txt_ma_cap_thu_tuc = get_post_var('txt_ma_cap_thu_tuc');
//       
        }
   // }

}

